<?php echo $this->Html->script("ZeroClipboard"); ?>
<?php echo $this->Html->script("TableTools"); ?>
<div id="filter" style="width: 217px; position: relative;display: none;">
        <select name="select-report" id="select-report">
            <option value=""> Select Customer Report Type </option>
            <option value="weekly">Weekly</option>
            <option value="monthly">Monthly</option>
            <option value="yearly">Yearly</option>
        </select>
</div>
<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
  <thead>	
    <tr>
			<th class="table-header-repeat line-left minwidth-1">
           <?php echo __('Name'); ?>
      </th>
			<th class="table-header-repeat line-left minwidth-1">
           <?php echo __('Email'); ?>
      </th>
			<th class="table-header-repeat line-left minwidth-1">
           <?php echo __('Username'); ?>
      </th>
			<th class="table-header-repeat line-left minwidth-1">
           <?php echo __('Balance'); ?>
      </th>
			<th class="table-header-repeat line-left">
           <?php echo __('Mobile'); ?>
      </th>
			<th class="table-header-repeat line-left">
           <?php echo __('Customer Type'); ?>
      </th>          
			<th class="table-header-repeat line-left">
           <?php echo __('Birthday'); ?>
      </th>          
			<th class="table-header-repeat line-left">
           <?php echo __('Country'); ?>
      </th>          
			<th class="table-header-repeat line-left">
           <?php echo __('City'); ?>
      </th>          
			<th class="table-header-repeat line-left">
           <?php echo __('date'); ?>
      </th>          
		</tr>
  </thead>
  <tbody>	
<?php foreach ($customers as $customer): ?>
    <tr>
        <td><?php echo $customer['Customer']['f_name'].' '.$customer['Customer']['l_name']; ?></td>
        <td>
            <?php echo $customer['Customer']['email']; ?>
        </td>
        <td>
            <?php echo $customer['Customer']['username']; ?>
        </td>
        <td>
            <?php echo $customer['Customer']['balance']; ?>
        </td>
        <td>
            <?php echo $customer['Customer']['mobile']; ?>
        </td>
        <td>
            <?php echo $customer['CustomerType']['name']; ?>
        </td>
        <td>
            <?php echo $customer['Customer']['birthday']; ?>
        </td>
        <td>
            <?php echo $customer['Country']['name']; ?>
        </td>
        <td>
            <?php echo $customer['City']['name']; ?>
        </td>
        <td>
            <?php echo date('Y-m-d', strtotime($customer['Customer']['created'])); ?>
        </td>
    </tr>
<?php endforeach; ?>
  </tbody>
</table>
	
<script type="text/javascript">
jQuery(document).ready( function () {
   date = "<?php echo date('M-d g i A') ?>";
  jQuery('#product-table').dataTable( {
        "bDestroy" : true,
        "bJQueryUI": true,
        "bSort": false,
        "oLanguage": {
            "sInfo": "_START_ - _END_ of _TOTAL_",
            "oPaginate": {
              
              "sFirst": " ",
              "sPrevious": " ",
              "sNext": " ",
              "sLast": " "
            }
        },
        "sPaginationType": "full_numbers",
        "bLengthChange": false,
        "bFilter": true,
        "sDom": '<"H"Tfr>t<"F"ip>',
        "oTableTools": {
          "aButtons": [
                 {
                    "sExtends": "xls",
                    "sFileName": "Loyalty_Customers-Report "+date+".xls"
                },
                 {
                    "sExtends": "pdf",
                    "sTitle": "Customers Report "+date+".",
                    "sFileName": "Loyalty_Customers-Report "+date+".pdf"
                }
          ],
           "sSwfPath": "<?php echo $this->webroot; ?>app/webroot/media/swf/copy_csv_xls_pdf.swf"
        },
      "fnDrawCallback": function (oSettings) {
          currentPage = Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength);
          totalPages = Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength);
          currentPage += 1;
          jQuery('#report-table_info').html('Page ' + currentPage + ' of ' + totalPages )
      }
    } );
   val = jQuery('#filter').html();
  jQuery('#product-table_filter').after(val);
});
</script>
